package com.dong.service;

import com.dong.dao.IAccountDao;
import com.dong.entity.Account;
import com.dong.entity.Orders;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;



@Service("accountService")
@Transactional
public class AccountService implements IAccountService {
    @Autowired
    private IAccountDao accountDao;

    public List<Account> findAll(int page,int size) {
        PageHelper.startPage(page, size);
        return accountDao.findAll();
    }


    public void saveAccount(Account account) {
        accountDao.saveAccount(account);
    }

    @Override
    public void delete(int id) {
        accountDao.delete(id);
    }

    @Override
    public void update(Account account) {
        accountDao.update(account);
    }

    @Override
    public Account checkName(String name) {
        return accountDao.checkName(name);
    }

    @Override
    public Account findById(int id) {
        return accountDao.findById(id);
    }

    @Override
    public List<Account> findByName(String name) {
        return accountDao.findByName(name);
    }

    /**
     *
     * @param id
     * @return
     */
    @Override
    public Account findAllByaid(int id) {
        return accountDao.findAllByaid(id);
    }

//    @Override
//    public List<Account> findAllOrders() {
//        return accountDao.findAll();
//    }
}
